import 'package:flutter_admin/utils/utils.dart';

class SaleOrderescortcode {
  String? id;
  String? escortcode;
  String? contractid;
  String? dateOrder;
  String? customercontractid;
  String? orderPartnerId;
  String? orderPartnerName;
  String? name;
  String? description;
  String? productUomQty;
  String? unit;

  SaleOrderescortcode({
    this.id,
    this.escortcode,
    this.contractid,
    this.dateOrder,
    this.customercontractid,
    this.orderPartnerId,
    this.orderPartnerName,
    this.name,
    this.description,
    this.productUomQty,
    this.unit,
  });

  SaleOrderescortcode copyWith({
    String? id,
    String? escortcode,
    String? contractid,
    String? dateOrder,
    String? customercontractid,
    String? orderPartnerId,
    String? orderPartnerName,
    String? name,
    String? description,
    String? productUomQty,
    String? unit,
  }) {
    return new SaleOrderescortcode(
      id: id ?? this.id,
      escortcode: escortcode ?? this.escortcode,
      contractid: contractid ?? this.id,
      dateOrder: dateOrder ?? this.dateOrder,
      customercontractid: customercontractid ?? this.customercontractid,
      orderPartnerId: orderPartnerId ?? this.orderPartnerId,
      orderPartnerName: orderPartnerName ?? this.orderPartnerName,
      name: name ?? this.name,
      description: description ?? this.description,
      productUomQty: productUomQty ?? this.productUomQty,
      unit: unit ?? this.unit,
    );
  }

  @override
  String toString() {
    return '''SaleOrderescortcode{
      id: id,
      escortcode: escortcode,
      contractid: contractid,
      dateOrder: dateOrder,
      customercontractid: customercontractid,
      orderPartnerId: orderPartnerId,
      orderPartnerName: orderPartnerName,
      name: name,
      description: description,
      productUomQty: productUomQty,
      unit: unit,
    }''';
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      (other is SaleOrderescortcode &&
          runtimeType == other.runtimeType &&
          id == other.id &&
          escortcode == other.escortcode &&
          contractid == other.contractid &&
          dateOrder == other.dateOrder &&
          customercontractid == other.customercontractid &&
          orderPartnerId == other.orderPartnerId &&
          orderPartnerName == other.orderPartnerName &&
          name == other.name &&
          description == other.description &&
          productUomQty == other.productUomQty &&
          unit == other.unit);

  factory SaleOrderescortcode.fromMap(Map<String, dynamic> map) {
    return new SaleOrderescortcode(
      id: map['id'] != false ? map['id'].toString() as String? : "",
      escortcode: map['escortcode'] != false
          ? map['escortcode'].toString() as String?
          : "",
      contractid: map['contractid'] != false
          ? map['contractid'].toString() as String?
          : "",
      dateOrder: map['date_order'] != false
          ? Utils.getDate(date: map['date_order'].toString())
          : "",
      customercontractid: map['customercontractid'] != false
          ? map['customercontractid'].toString() as String?
          : "",
      orderPartnerId: map['order_partner_id'] != false
          ? map['order_partner_id'].toString() as String?
          : "",
      orderPartnerName: map['order_partner_id'] != false
          ? map['order_partner_id'][1].toString() as String?
          : "",
      name: map['name'] != false ? map['name'].toString() as String? : "",
      description: map['description'] != false
          ? map['description'].toString() as String?
          : "",
      productUomQty: map['product_uom_qty'] != false
          ? map['product_uom_qty'].toString() as String?
          : "",
      unit: map['unit'] != false ? map['unit'].toString() as String? : "",
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'escortcode': this.escortcode,
      'contractid': this.contractid,
      'dateOrder': this.dateOrder,
      'customercontractid': this.customercontractid,
      'orderPartnerId': this.orderPartnerId,
      'orderPartnerName': this.orderPartnerName,
      'name': this.name,
      'description': this.description,
      'productUomQty': this.productUomQty,
      'unit': this.unit,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      if (this.contractid != null && this.contractid != '')
        ['contractid', '=', this.contractid],
    ] as List;
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'contractid': this.contractid,
      'escortcode': this.escortcode,
      'dateOrder': this.dateOrder,
      'customercontractid': this.customercontractid,
      'orderPartnerId': this.orderPartnerId,
      'orderPartnerName': this.orderPartnerName,
      'name': this.name,
      'description': this.description,
      'productUomQty': this.productUomQty,
      'unit': this.unit,
    } as Map<String, dynamic>;
  }

//</editor-fold>

}
